import { Router, Route, Switch, Redirect } from 'react-router-dom'
import Login from './pages/Login'
import Layout from './pages/Layout'
import AuthRoute from './components/AuthRoute'
import NotFound from './pages/NotFound'
import history from './utils/history'
import 'moment/locale/zh-cn'
import locale from 'antd/lib/locale/zh_CN'
import { ConfigProvider } from 'antd'

function App() {
  return (
    <ConfigProvider locale={locale}>
      <Router history={history}>
        <div className='App'>
          <Switch>
            <Redirect exact to={'/login'} from={'/'}></Redirect>
            {/*
          <Route path={'/login'} component={Login}></Route>
          <Route path={'/home'} component={Layout}></Route>*/}
            <Route
              path={'/login'}
              render={(defaultProps) => <Login {...defaultProps} />}></Route>
            <AuthRoute path={'/home'} component={Layout}></AuthRoute>
            <Route component={NotFound}></Route>
            {/*       <Route
            path={'/home'}
            render={(defaultProps) => {
              if (isToken()) {
                return <Layout {...defaultProps}></Layout>
              } else {
                return <Redirect to={'/login'} />
              }
            }}></Route>*/}
          </Switch>
        </div>
      </Router>
    </ConfigProvider>
  )
}

export default App
